package com.fau.wmbj.server.entity;

import com.fau.wmbj.server.flowable.pojo.ProcessModel;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 模板
 *
 * @author jiawei
 * @version 1.0
 * @datetime 2024-03-25 9:12
 */
@Getter
@Setter
@Entity(name = "f_template")
@org.hibernate.annotations.Table(appliesTo = "f_template", comment = "模板")
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class Template extends BaseEntity<Long> implements Serializable {

    /**
     * 名称
     */
    @Column(name = "name", nullable = false)
    private String name;


    /**
     * 所属公司
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "company_id")
    private Company company;

    /**
     * 表格
     */
    @Lob
    @Column(name = "table_data")
    @Type(type = "json")
    private Map<String, Object> tableData = new HashMap<>();

    /**
     * 工作流
     */
    @Lob
    @Column(name = "flow_data")
    @Type(type = "json")
    private Map<String, Object> flowData = new HashMap<>();

    /**
     * 表单
     */
    @Lob
    @Column(name = "form_data")
    @Type(type = "json")
    private Map<String, Object> formData = new HashMap<>();

    // /**
    //  * 角色
    //  */
    // @Lob
    // @Column(name = "role_data")
    // @Type(type = "json")
    // private List<Map<String, Object>> roleData = new ArrayList<>();

    @Transient
    private Boolean isDefault;
    @Transient
    private List<Map<String, Object>> baseParameter = new ArrayList<>();
    @Transient
    private List<Map<String, Object>> body = new ArrayList<>();
    @Transient
    private Integer headerRow;
    @Transient
    private List<Long> ids = new ArrayList<>();
    @Transient
    private List<Map<String, Object>> role = new ArrayList<>();
    @Transient
    private ProcessModel processModel;
}
